﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace VisualWip.PresentationModel
{
    public class BooleanToScrollBarVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                if (parameter == null)
                    return (bool)value ? ScrollBarVisibility.Auto : ScrollBarVisibility.Hidden;

                var myParameter = parameter.ToString().Trim();
                if (myParameter == "Visible")
                {
                    return (bool)value ? ScrollBarVisibility.Visible : ScrollBarVisibility.Hidden;
                }
                return (bool)value ? ScrollBarVisibility.Auto : ScrollBarVisibility.Hidden;
            }
            catch
            {
                return DependencyProperty.UnsetValue;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}